o->deleteLater();
} else {
// If the object is C++-owned, we still have to release the weak reference we have
- // to it.
- ddata->jsWrapper.clear();
- if (lastCall && ddata->propertyCache)
- ddata->propertyCache.reset();
+ // to it. If the "main" wrapper is not ours, we should leave it alone, though.
+ if (ddata->jsWrapper.as<QObjectWrapper>() == this)
+ ddata->jsWrapper.clear();
}
}
}
engine.newQObject(obj.data());
QVERIFY(QQmlData::get(obj.data())->propertyCache);
}
- QVERIFY(!QQmlData::get(obj.data())->propertyCache);
+ QVERIFY(QQmlData::get(obj.data())->propertyCache);
}
void tst_QJSEngine::newQMetaObject() {
void stringLength();
void stringToByteArray();
void structuredValueType();
+ void multiEnginePropertyCache();
void takeNumbers();
void takeNumbers_data();
void testIsnan();
QCOMPARE(o->property("w2").value<WeatherModelUrl>(), w2);
}
+void tst_QmlCppCodegen::multiEnginePropertyCache()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/multiEnginePropertyCache.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ std::unique_ptr<QObject> o(c.create());
+ QVERIFY(o);
+
+ {
+ QJSEngine other;
+ other.newQObject(o.get());
+ }
+
+ QTest::ignoreMessage(QtDebugMsg, "close1");
+ o->setProperty("foo", 1);
+
+ QTest::ignoreMessage(QtDebugMsg, "close2");
+ o->setProperty("bar", 2);
+}
+
void tst_QmlCppCodegen::takeNumbers()
{
QFETCH(QByteArray, method);